import request from "@/api/index.js"

// 获取商品详情
export function getGoodsContentApi(goodsId) {
  return request({
    url: `/IntactGoods?goodsId=${goodsId}`,
    method: "get"
  })
}
// 关注与取消关注
export function postUserFollowApi(uid) {
  return request({
    url: `/fans/addFollow?followUserId=${uid}`,
    method: "post"
  })
}

// 获取评论列表
export function getCommentsApi(goodsId, page = 1, parentId = null) {
  let parentIdStr = parentId != null ? `&parentId=${parentId}` : ''
  return request({
    url: `/comments?goodsId=${goodsId}&page=${page}` + parentIdStr,
    method: "get"
  })
}


// 发送评论
export function postSendOutApi(content, id, parentId = "0") {
  return request({
    url: `/comments`,
    method: "post",
    data: {
      "targetId": id, //物品id
      "content": content, //插入内容
      "parentId": parentId, //如果是零就是一级评论 其他的就是二级评论
      "link": "0" //图片链接
    }
  })
}
// 删除评论
export function deleteReplyApi(commentId) {
  return request({
    url: `/comments?commentId=${commentId}`,
    method: "delete"
  })
}

// 评论点赞
export function postreplyThumbsUpApi(cid) {
  return request({
    url: `/comments-like?id=${cid}`,
    method: "put"
  })
}
